﻿@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

<div @attributes="@AdditionalAttributes" class="@ClassString">
    <CascadingValue Value="this" IsFixed="true">
        @ChildContent
    </CascadingValue>
    <RenderTemplate>
        <ul class="nav d-inline-flex">
            @foreach (var item in GetItems())
            {
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-bs-toggle="dropdown" title="@item.Title">
                        <i class="@item.Icon"></i>
                        @if (!string.IsNullOrEmpty(item.BadgeNumber))
                        {
                            <Badge Color="@item.BadgeColor">@item.BadgeNumber</Badge>
                        }
                    </a>
                    <div class="dropdown-menu shadow">
                        @if (item.ShowArrow)
                        {
                            <div class="dropdown-arrow arrow-@item.HeaderColor.ToDescriptionString()"></div>
                        }
                        @if (item.HeaderTemplate != null)
                        {
                            <div class="dropdown-header bg-@item.HeaderColor.ToDescriptionString()">
                                @item.HeaderTemplate
                            </div>
                        }
                        <div class="dropdown-body">
                            @item.BodyTemplate
                        </div>
                        @if (item.FooterTemplate != null)
                        {
                            <div class="dropdown-footer">
                                @item.FooterTemplate
                            </div>
                        }
                    </div>
                </li>
            }
        </ul>
    </RenderTemplate>
</div>
